# Maintainer: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Surain Mallawa Arachchi <mas@crc32.net>

pkgname=linux-atm
pkgver=2.5.2
pkgrel=8
pkgdesc="Drivers and tools to support ATM networking under Linux."
arch=('x86_64')
depends=('glibc')
optdepends=('flex: for atmsigd')
url="http://linux-atm.sourceforge.net/"
license=(GPL)
source=(https://downloads.sourceforge.net/sourceforge/${pkgname}/${pkgname}-${pkgver}.tar.gz
        linux-atm-man-pages.patch
        linux-atm-remove-define-hacks.patch
        linux-atm-linux-5.2-SIOCGSTAMP.patch
        linux-atm-string-formatting.patch)
options=(!makeflags)
sha256sums=('9645481a2b16476b59220aa2d6bc5bc41043f291326c9b37581018fbd16dd53a'
            '0e535ace1a88d4bba95a586f9357a6fef5258e07ffeba209d630e32149dfaa07'
            'd894e81b77dfe376bc9d917799e397be7e2fc28bc8ef657ee3fadccbf7e66c76'
            'df2ed44ec81576f014a75a0d7029fab7366a65b21a4beed0c18812b7886aa202'
            '8cac3c3703b80606b537611865a37e83b271295a34e563a2c62c5644b75bdd0f')

prepare() {
  cd "${pkgname}-${pkgver}"
  patch -Np1 -i ../linux-atm-man-pages.patch
  patch -Np1 -i ../linux-atm-remove-define-hacks.patch
  patch -Np1 -i ../linux-atm-linux-5.2-SIOCGSTAMP.patch
  patch -Np1 -i ../linux-atm-string-formatting.patch

  # install firmware in /usr/lib
  sed -i "s#/lib/firmware#/usr/lib/firmware#" src/extra/Makefile.in
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --prefix=/usr --sbindir=/usr/bin --sysconfdir=/etc
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
}
